{{define "log/index.html"}}
{{template "header" .}}
{{template "table" .}}

<title>运行日志</title>


<script type="text/html" id="TplLevel">
    {{ `{{formatLevel(d.Level)}}` }}
    </script>

<script type="text/html" id="TplTime">
    {{ `{{formatTime(d.Time)}}` }}
    </script>
</head>
<body>

    <!---------主数据表--------->
    <table id="table" lay-filter="toolbar"> </table>
    <script type="text/javascript">
        //格式化时间
        function formatTime(value) {
            return  fecha.format(new Date(value * 1000), "YYYY/MM/DD HH:mm:ss") ;
        }
        //格式化类型
        function formatLevel(value) {
            if (value == 0) {
                return 'Emergency';
            } else if (value == 1) {
                return 'Alert';
            } else if (value == 2) {
                return 'Critical';
            } else if (value == 3) {
                return 'Error';
            } else if (value == 4) {
                return 'Warn';
            } else if (value == 5) {
                return 'Notice';
            } else if (value == 6) {
                return 'Info';
            } else if (value == 7) {
                return 'Debug';
            }
            return 'Error';
        }

        layui.use(['table', 'layer'], function () {
            var table = layui.table;
            var curPage = 1;
            var form = layui.form;
            tableOption.url = '/v1/log/index';
            tableOption.done = function (res, curr, count) { curPage = curr; }
            tableOption.cols = [[
                { type: 'numbers', title: '序号', width: 50 },
                { field: 'Time', width: 180, title: '时间', sort: true, templet: '#TplTime' },
                { field: 'Level', width: 80, title: '级别', sort: true, templet: '#TplLevel' },
                { field: 'Msg', title: '消息', sort: true }
            ]]
            var tableIns = table.render(tableOption);
        }); 
    </script>
</body>

</html>

{{end}}